﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
using SharedLibraries.Constants;
using EntityObject;
using ThangNM_LIB.FUNC;
using ThangNM_LIB.EO;

namespace SharedLibraries
{
    public class GetListConstants
    {
        public static String getValueKeyInSortedList(SortedList lst, Object sValue, Boolean isGetKey)
        {
            String ret = "";
            Int32 index = -1;
            Int32 iKey;
            String sKey;
            try
            {
                if (isGetKey)
                {
                    index = lst.IndexOfValue(sValue);
                    if (index < 0)
                        ret = "";
                    else
                        ret = Convert.ToString(lst.GetKey(index));
                }
                else
                {
                    if (sValue is Int16 || sValue is Int32 || sValue is Int64)
                    {
                        iKey = Convert.ToInt32(sValue);
                        index = lst.IndexOfKey(iKey);
                    }
                    else if (sValue is String)
                    {
                        sKey = Convert.ToString(sValue);
                        index = lst.IndexOfKey(sKey);
                    }

                    if (index < 0)
                        ret = "";
                    else
                        ret = Convert.ToString(lst.GetByIndex(index));
                }
            }
            catch (Exception ex)
            {
                (new Logs()).WriteLog_To_DB(new LogEO(ex.ToString(), ConstEx.Log_iType.EXCEPTION), false);
            }
            return ret;
        }

        public static List<TableEO> Table_Name_GLC()
        {
            List<TableEO> lstTable = new List<TableEO>();
            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.Default, sName = "[Trang chủ]", sTitle = "Trang chủ", sTitleEx = "Trang chủ" });
            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.Category, sName = "[Danh mục]", sTitle = "", sTitleEx = " | Danh mục bài viết" });
            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.Topic, sName = "[Bài viết]", sTitle = "", sTitleEx = "" });
            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.Media, sName = "[Giải trí]", sTitle = "", sTitleEx = " | Giải trí" });
            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.QuestionAnswer, sName = "[Hỏi - Đáp]", sTitle = "Hỏi - Đáp", sTitleEx = " | Hỏi - Đáp" });
            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.Account, sName = "[Tài khoản]", sTitle = "", sTitleEx = "" });
            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.File, sName = "[Chia sẻ File]", sTitle = "", sTitleEx = " | Tải file" });
            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.Quiz, sName = "[Thi trắc nghiệm - Đố]", sTitle = "", sTitleEx = "" });
            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.Function, sName = "[Chức năng hệ thống]", sTitle = "", sTitleEx = "" });
            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.Sitemap, sName = "[Bản đồ website]", sTitle = "", sTitleEx = "" });
            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.Temp, sName = "", sTitle = "", sTitleEx = "" });
            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.Database, sName = "[Cơ sở dữ liệu SQL Server]", sTitle = "", sTitleEx = "" });

            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.Tag, sName = "[Nhãn]", sTitle = "", sTitleEx = "" });
            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.Error, sName = "[Lỗi hệ thống]", sTitle = "", sTitleEx = "" });
            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.EditSourceFile, sName = "[Chỉnh sửa file]", sTitle = "", sTitleEx = "" });
            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.Group, sName = "[Nhóm bài viết]", sTitle = "", sTitleEx = "" });
            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.BackLink, sName = "[Liên kết link]", sTitle = "", sTitleEx = "" });

            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.Advertise, sName = "[Quảng cáo]", sTitle = "", sTitleEx = "" });
            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.MetaTag, sName = "[Thẻ SEO]", sTitle = "", sTitleEx = "" });
            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.NewsLetter, sName = "[Đăng ký nhận tin]", sTitle = "", sTitleEx = "" });
            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.Permission, sName = "[Phân quyền cho người dùng]", sTitle = "", sTitleEx = "" });
            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.TSQL, sName = "[Truy vấn Database SQL Server]", sTitle = "", sTitleEx = "" });

            lstTable.Add(new TableEO { iTableID = ConstEx.TableID_C.SEO, sName = "[Tối ưu công cụ tìm kiếm - SEO]", sTitle = "", sTitleEx = "" });

            return lstTable;
        }

        public static String getTableName(Int16 _id, Int16 _type)
        {
            TableEO obj = Table_Name_GLC().Find(i => i.iTableID == _id);
            if (obj != null)
            {
                switch (_type)
                {
                    case TYPE.sName: return obj.sName; break;
                    case TYPE.sTitle: return obj.sTitle; break;
                    case TYPE.sTitleEx: return obj.sTitleEx; break;
                    default: return ""; break;
                }
            }
            return "";

        }

        #region "I. Constants - GetTextConstants - GetListConstants"
        public static SortedList Robots_GLC()
        {
            SortedList output = new SortedList();
            output.Add(0, "all");           //There are no restrictions for indexing or serving. Note: this directive is the default value and has no effect if explicitly listed.
            output.Add(1, "noindex");       //Do not show this page in search results and do not show a "Cached" link in search results.
            output.Add(2, "nofollow");      //Do not follow the links on this page
            output.Add(3, "none");          //Equivalent to noindex, nofollow.
            output.Add(4, "noarchive");     //Do not show a "Cached" link in search results
            output.Add(5, "nosnippet");     //Do not show a snippet in the search results for this page
            output.Add(6, "noodp");         //Do not use metadata from the Open Directory project for titles or snippets shown for this page.
            output.Add(7, "notranslate");   //Do not offer translation of this page in search results.
            output.Add(8, "noimageindex");  //Do not index images on this page.
            return output;
        }

        public static SortedList Changefreq_GLC()
        {
            SortedList output = new SortedList();
            output.Add(0, "always");
            output.Add(1, "hourly");
            output.Add(2, "daily");
            output.Add(3, "weekly");
            output.Add(4, "monthly");
            output.Add(5, "yearly");
            output.Add(6, "never");
            return output;
        }

        public static SortedList CongCu()
        {
            SortedList output = new SortedList();
            output.Add(100, "Công cụ chuỗi/ký tự");
            output.Add(101, "Đếm số ký tự");
            output.Add(102, "Đếm số từ");
            output.Add(103, "Chuyển chữ hoa toàn bộ");
            output.Add(104, "Chuyển chữ thường toàn bộ");
            output.Add(105, "Chữ hoa chữ cái đầu");
            output.Add(106, "Đảo ngược chuỗi");

            output.Add(200, "Công cụ mã hóa/giải mã");
            output.Add(201, "Mã hóa MD5");
            output.Add(202, "Mã hóa SHA1");
            output.Add(203, "Mã hóa URL");
            output.Add(204, "Giải mã URL");
            output.Add(205, "Mã hóa HTML");
            output.Add(206, "Giải mã HTML");

            output.Add(300, "Công cụ tự động");
            output.Add(301, "Sinh mật khẩu tự động");
            output.Add(302, "Sinh số tự động");
            output.Add(303, "Tạo mã vạch QR Code");
            output.Add(304, "Tạo mã vạch Bar Code");
            output.Add(305, "Đóng dấu ảnh");


            output.Add(400, "Công cụ chuyển đổi");
            output.Add(401, "String to Hex");
            output.Add(402, "Hex to String");
            output.Add(403, "String to Binary");
            output.Add(404, "Binary to String");
            output.Add(405, "String to Base64");
            output.Add(406, "Base64 to String");
            output.Add(407, "Decimal to Binary");
            output.Add(408, "Binary to Decimal");
            output.Add(409, "Decimal to Hex");
            output.Add(410, "Hex to Decimal");

            output.Add(500, "Công cụ về màu sắc");
            output.Add(501, "Color to Hex");
            output.Add(502, "Color to RBG");
            output.Add(503, "Color to Name");

            output.Add(600, "Công cụ tính toán");
            output.Add(601, "Máy tính bỏ túi");

            output.Add(700, "Công cụ khác");
            return output;
        }

        /// <summary> ChangeFreq_GLC (Tần số thay đổi) </summary>
        /// <returns>output</returns>
        public static SortedList ChangeFreq_GLC()
        {
            SortedList output = new SortedList();
            output.Add(ChangeFreq_C.always, GetTextConstants.ChangeFreq_GTC(ChangeFreq_C.always));
            output.Add(ChangeFreq_C.hourly, GetTextConstants.ChangeFreq_GTC(ChangeFreq_C.hourly));
            output.Add(ChangeFreq_C.daily, GetTextConstants.ChangeFreq_GTC(ChangeFreq_C.daily));
            output.Add(ChangeFreq_C.weekly, GetTextConstants.ChangeFreq_GTC(ChangeFreq_C.weekly));
            output.Add(ChangeFreq_C.monthly, GetTextConstants.ChangeFreq_GTC(ChangeFreq_C.monthly));
            output.Add(ChangeFreq_C.yearly, GetTextConstants.ChangeFreq_GTC(ChangeFreq_C.yearly));
            output.Add(ChangeFreq_C.never, GetTextConstants.ChangeFreq_GTC(ChangeFreq_C.never));
            return output;
        }

        /// <summary> Sitemap_Type_GLC </summary>
        /// <returns>output</returns>
        public static SortedList Sitemap_Type_GLC()
        {
            SortedList output = new SortedList();
            output.Add(ConstEx.TableID_C.Category, GetTextConstants.Sitemap_Type_GTC(ConstEx.TableID_C.Category));
            output.Add(ConstEx.TableID_C.Topic, GetTextConstants.Sitemap_Type_GTC(ConstEx.TableID_C.Topic));
            output.Add(ConstEx.TableID_C.Media, GetTextConstants.Sitemap_Type_GTC(ConstEx.TableID_C.Media));
            output.Add(ConstEx.TableID_C.QuestionAnswer, GetTextConstants.Sitemap_Type_GTC(ConstEx.TableID_C.QuestionAnswer));
            output.Add(ConstEx.TableID_C.Account, GetTextConstants.Sitemap_Type_GTC(ConstEx.TableID_C.Account));
            output.Add(ConstEx.TableID_C.File, GetTextConstants.Sitemap_Type_GTC(ConstEx.TableID_C.File));
            return output;
        }

        public static SortedList Sitemap_Status_GLC()
        {
            SortedList output = new SortedList();
            output.Add(true, true);
            output.Add(false, false);
            return output;
        }

        ///// <summary> Media_iType_GLC (Nhóm giải trí) </summary>
        ///// <returns>output</returns>
        //public static SortedList Media_iType_GLC()
        //{
        //    SortedList output = new SortedList();
        //    output.Add(Convert.ToInt16(0), "");
        //    output.Add(Media_iType_C.Choi_Game, GetTextConstants.Media_iType_GTC(Media_iType_C.Choi_Game));
        //    output.Add(Media_iType_C.Tai_Game, GetTextConstants.Media_iType_GTC(Media_iType_C.Tai_Game));
        //    output.Add(Media_iType_C.Xem_Phim_TV_Online, GetTextConstants.Media_iType_GTC(Media_iType_C.Xem_Phim_TV_Online));
        //    output.Add(Media_iType_C.Nghe_Nhac_Radio, GetTextConstants.Media_iType_GTC(Media_iType_C.Nghe_Nhac_Radio));
        //    output.Add(Media_iType_C.Sach_Truyen, GetTextConstants.Media_iType_GTC(Media_iType_C.Sach_Truyen));
        //    output.Add(Media_iType_C.Hinh_Anh_Dong, GetTextConstants.Media_iType_GTC(Media_iType_C.Hinh_Anh_Dong));
        //    output.Add(Media_iType_C.Doc_Va_La, GetTextConstants.Media_iType_GTC(Media_iType_C.Doc_Va_La));
        //    output.Add(Media_iType_C.Ung_Dung, GetTextConstants.Media_iType_GTC(Media_iType_C.Ung_Dung));
        //    return output;
        //}

        /// <summary> Topic_iStatus_GLC (Trạng thái bài viết) </summary>
        /// <returns>output</returns>
        public static SortedList Topic_iStatus_GLC(Boolean isAll)
        {
            SortedList output = new SortedList();
            if (isAll)
                output.Add(Convert.ToInt16(0), "-- Tất cả -- ");
            output.Add(Topic_iStatus_C.Approved, GetTextConstants.Topic_iStatus_GTC(Topic_iStatus_C.Approved));
            output.Add(Topic_iStatus_C.Pending, GetTextConstants.Topic_iStatus_GTC(Topic_iStatus_C.Pending));
            output.Add(Topic_iStatus_C.Deleted, GetTextConstants.Topic_iStatus_GTC(Topic_iStatus_C.Deleted));
            return output;
        }

        /// <summary> Topic_sCode_GLC (Trạng thái bài viết) </summary>
        /// <returns>output</returns>
        public static SortedList Topic_sCode_GLC()
        {
            SortedList output = new SortedList();
            output.Add(Topic_sCode_C.shBrushA3, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushA3));
            output.Add(Topic_sCode_C.shBrushBash, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushBash));
            output.Add(Topic_sCode_C.shBrushColdFusion, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushColdFusion));
            output.Add(Topic_sCode_C.shBrushCpp, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushCpp));
            output.Add(Topic_sCode_C.shBrushCSharp, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushCSharp));
            output.Add(Topic_sCode_C.shBrushCss, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushCss));
            output.Add(Topic_sCode_C.shBrushDelphi, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushDelphi));
            output.Add(Topic_sCode_C.shBrushDiff, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushDiff));
            output.Add(Topic_sCode_C.shBrushErlang, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushErlang));
            output.Add(Topic_sCode_C.shBrushGroovy, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushGroovy));
            output.Add(Topic_sCode_C.shBrushJava, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushJava));
            output.Add(Topic_sCode_C.shBrushJavaFX, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushJavaFX));
            output.Add(Topic_sCode_C.shBrushJScript, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushJScript));
            output.Add(Topic_sCode_C.shBrushPerl, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushPerl));
            output.Add(Topic_sCode_C.shBrushPhp, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushPhp));
            output.Add(Topic_sCode_C.shBrushPlain, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushPlain));
            output.Add(Topic_sCode_C.shBrushPowerShell, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushPowerShell));
            output.Add(Topic_sCode_C.shBrushPython, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushPython));
            output.Add(Topic_sCode_C.shBrushRuby, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushRuby));
            output.Add(Topic_sCode_C.shBrushScala, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushScala));
            output.Add(Topic_sCode_C.shBrushSql, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushSql));
            output.Add(Topic_sCode_C.shBrushVb, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushVb));
            output.Add(Topic_sCode_C.shBrushXml, GetTextConstants.Topic_sCode_GTC(Topic_sCode_C.shBrushXml));
            return output;
        }

        public static SortedList Category_bStatus_GLC()
        {
            SortedList output = new SortedList();
            output.Add(true, "Mở");
            output.Add(false, "Khóa");
            return output;
        }

        public static SortedList Category_iType_GLC()
        {
            SortedList output = new SortedList();
            output.Add(Convert.ToInt16(0), "");
            output.Add(ConstEx.TableID_C.Category, GetTextConstants.Category_iType_GTC(ConstEx.TableID_C.Category));
            output.Add(ConstEx.TableID_C.Topic, GetTextConstants.Category_iType_GTC(ConstEx.TableID_C.Topic));
            output.Add(ConstEx.TableID_C.Media, GetTextConstants.Category_iType_GTC(ConstEx.TableID_C.Media));
            output.Add(ConstEx.TableID_C.Answer, GetTextConstants.Category_iType_GTC(ConstEx.TableID_C.Answer));
            output.Add(ConstEx.TableID_C.Account, GetTextConstants.Category_iType_GTC(ConstEx.TableID_C.Account));
            output.Add(ConstEx.TableID_C.File, GetTextConstants.Category_iType_GTC(ConstEx.TableID_C.File));
            output.Add(ConstEx.TableID_C.Quiz, GetTextConstants.Category_iType_GTC(ConstEx.TableID_C.Quiz));
            output.Add(ConstEx.TableID_C.Other, GetTextConstants.Category_iType_GTC(ConstEx.TableID_C.Other));
            return output;
        }

        /// <summary> I.2. Account_iPermission_GLC (Quyền Hạn Tài Khoản) </summary>
        /// <returns></returns>
        public static SortedList Account_iPermission_GLC()
        {
            SortedList output = new SortedList();
            output.Add(Account_iPermission_C.Administrator, GetTextConstants.Account_iPermission_GTC(Account_iPermission_C.Administrator));
            output.Add(Account_iPermission_C.Editor, GetTextConstants.Account_iPermission_GTC(Account_iPermission_C.Editor));
            output.Add(Account_iPermission_C.Visistor, GetTextConstants.Account_iPermission_GTC(Account_iPermission_C.Visistor));
            output.Add(Account_iPermission_C.Followers, GetTextConstants.Account_iPermission_GTC(Account_iPermission_C.Followers));
            output.Add(Account_iPermission_C.Anonymous, GetTextConstants.Account_iPermission_GTC(Account_iPermission_C.Anonymous));
            return output;
        }

        public static SortedList ExtendFile_GLC()
        {
            SortedList output = new SortedList();
            output.Add(ExtendFile_C.FLV, ".FLV");
            output.Add(ExtendFile_C.MP4, ".MP4");
            output.Add(ExtendFile_C.OGG, ".OGG");
            output.Add(ExtendFile_C.WEBM, ".WEBM");
            output.Add(ExtendFile_C.F4V, ".F4V");
            output.Add(ExtendFile_C.MKV, ".MKV");
            output.Add(ExtendFile_C.AVI, ".AVI");
            output.Add(ExtendFile_C._3G2, ".3G2");
            output.Add(ExtendFile_C.MOV, ".MOV");
            output.Add(ExtendFile_C.MPG, ".MPG");
            output.Add(ExtendFile_C.WMV, ".WMV");
            output.Add(ExtendFile_C.JPG, ".JPG");
            output.Add(ExtendFile_C.PNG, ".PNG");
            output.Add(ExtendFile_C.GIF, ".GIF");
            output.Add(ExtendFile_C.SWF, ".SWF");
            output.Add(ExtendFile_C.ZIP, ".ZIP");
            output.Add(ExtendFile_C.RAR, ".RAR");
            output.Add(ExtendFile_C.HTML, ".HTML");
            output.Add(ExtendFile_C.CSS, ".CSS");
            output.Add(ExtendFile_C.JS, ".JS");
            output.Add(ExtendFile_C.JAVA, ".JAVA");
            output.Add(ExtendFile_C.CS, ".CS");
            output.Add(ExtendFile_C.VB, ".VB");
            output.Add(ExtendFile_C.TXT, ".TXT");
            output.Add(ExtendFile_C.JSON, ".JSON");
            output.Add(ExtendFile_C.XML, ".XML");
            output.Add(ExtendFile_C.DOC, ".DOC");
            output.Add(ExtendFile_C.DOCX, ".DOCX");
            output.Add(ExtendFile_C.XLS, ".XLS");
            output.Add(ExtendFile_C.XLSX, ".XLSX");
            output.Add(ExtendFile_C.PPT, ".PPT");
            output.Add(ExtendFile_C.PPTX, ".PPTX");
            return output;
        }

        public static SortedList File_iServer_GLC()
        {
            SortedList output = new SortedList();
            output.Add(File_iServer_C.Google_Code, GetTextConstants.File_iServer_GTC(File_iServer_C.Google_Code));
            output.Add(File_iServer_C.Google_Driver, GetTextConstants.File_iServer_GTC(File_iServer_C.Google_Driver));
            output.Add(File_iServer_C.Dropbox, GetTextConstants.File_iServer_GTC(File_iServer_C.Dropbox));
            output.Add(File_iServer_C.Box, GetTextConstants.File_iServer_GTC(File_iServer_C.Box));
            output.Add(File_iServer_C.One_Driver, GetTextConstants.File_iServer_GTC(File_iServer_C.One_Driver));
            output.Add(File_iServer_C.Media_Fire, GetTextConstants.File_iServer_GTC(File_iServer_C.Media_Fire));
            return output;
        }

        public static SortedList Function_Attach_GLC()
        {
            SortedList output = new SortedList();
            output.Add(ConstEx.funcButtonToolBar.INSERT_LIST, "thêm ds");
            output.Add(ConstEx.funcButtonToolBar.INSERT_ITEM, "thêm");
            output.Add(ConstEx.funcButtonToolBar.UPDATE_ITEM, "sửa");
            output.Add(ConstEx.funcButtonToolBar.DELETE_LIST, "xóa ds");
            output.Add(ConstEx.funcButtonToolBar.DELETE_ITEM, "xóa");
            output.Add(ConstEx.funcButtonToolBar.REFRESH_LIST, "làm mới ds");
            output.Add(ConstEx.funcButtonToolBar.EXPORT_EXCEL, "xuất file");
            output.Add(ConstEx.funcButtonToolBar.RESET_FORM, "làm mới form");
            output.Add(ConstEx.funcButtonToolBar.PREVIEW_TOPIC, "xem trước");
            return output;
        }

        public static SortedList Wedding_iGroom_GLC()
        {
            SortedList output = new SortedList();
            output.Add(0, "-- Tất cả --");
            output.Add(1, "Nhà trai");
            output.Add(2, "Nhà gái");
            output.Add(3, "Nhà trai + Nhà gái");
            return output;
        }

        public static SortedList Wedding_iStatus_GLC()
        {
            SortedList output = new SortedList();
            output.Add(0, "-- Chưa chọn --");
            output.Add(1, "Chưa mời");
            output.Add(2, "Đã mời");
            output.Add(3, "Hủy");
            output.Add(9, "Đợi xem xét lại");
            return output;
        }
        #endregion
    }
}